package gui;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.ImageObserver;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

@SuppressWarnings("serial")
public class ImageLabel extends JLabel {
	private Image image;
	private ImageObserver imageObserver;

	public ImageLabel(String filePath) {
		ImageIcon icon = new ImageIcon(filePath);
		image = icon.getImage();
		imageObserver = icon.getImageObserver();
	}

	public void changeImage(String filePath) {
		ImageIcon icon = new ImageIcon(filePath);
		image = icon.getImage();
		imageObserver = icon.getImageObserver();
		repaint();
	}

	protected void paintComponent(Graphics g) {
		g.drawImage(image, 0, 0, getWidth(), getHeight(), imageObserver);
		super.paintComponent(g);
	}
}
